<template>
    <div>
        {{ info  }}
        <table class="table table-brodered ">
            <thead>
                <tr>
                    <td>房型号</td>
                    <td><input type="text" v-model="info.zName" ></td>
                </tr>

                

                <tr>
                    <td>房型</td>
                    <td><select  v-model="info.fid" >
                        <option value="">请选择</option>
                        <option :value="o.fid" v-for="o in vou"  >{{ o.fName }}</option>
                    </select></td>
                </tr>

                <tr>
                    <td>状态</td>
                    <td><select  v-model="info.state" >
                        <option value="">请选择</option>
                        <option value="1">空房</option>
                        <option value="2">禁用</option>
                        <option value="3">启用</option>
                    </select></td>
                </tr>
                <tr>
                    <td>备注</td>
                    <td><textarea  v-model="info.bei" ></textarea></td>
                </tr>
                
                <tr>
                    <td></td>
                    <td><input type="button" value="添加" @click="Add"></td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';


let vou:any=ref([]);

let info:any=ref({
  "zName": "",
  "fid": "",
  "bei": "",
  "state": "",
  "isDell": 0
})

onMounted(()=>{
    List();
} )

const List=()=>{
    axios({
        url:'https://localhost:7124/api/User/LisrF',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        vou.value=res.data;
    })
}




const Add=()=>{
    if(info.value.zName=="" )
{
    alert("房型号不为空");
    return;
}
    if(info.value.fid=="" )
{
    alert("房型不为空");
    return;
}
if(info.value.state=="" )
{
    alert("状态不为空");
    return;
}
if(info.value.bei=="" )
{
    alert("备注不为空");
    return;
}
    



    axios({
        url:'https://localhost:7124/api/User/AddZ',
        method:'post',
        data:info.value
    })
    .then((res)=>{
        console.log(res);
        if(res.data==-1)
    {
        alert("房型号重复");
        return;  
    }
        if(res.data>0 )
    {
        alert("成功");
    }
    })
    
}


</script>

<style scoped>

</style>